I need to join multiple tables using repository pattern & Entity Framework (using C#). Is this possible?
If so, please let me know how to do the same.
Thanks in advance!
Home / DeveloperSection / Forums / How to join Multiple tables using Repository Pattern & Entity Framework?
I need to join multiple tables using repository pattern & Entity Framework (using C#). Is this possible?
If so, please let me know how to do the same.
Thanks in advance!
Pravesh Singh
17-Dec-2013Hi Ashish,
In EF, joining tables is done through the use of Navigation Properties. Basically, EF does it for you. When implementing in your Repositories, may it be Generic or not, you can call the Include method when building your query expression to tell EF to populate the navigation properties for you.
Here's a sample code snippet using Include:
And for multiple tables you can nest the include method like so:
Once you include nav properties then that is basically joining those other tables. Just look at the SQL being generated by the query. Hope this helps!